package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.AuthPc;
import com.ruoyi.system.service.IAuthPcService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 授权计算机Controller
 * 
 * @author ruoyi
 * @date 2022-10-10
 */
@RestController
@RequestMapping("/auth/pc")
public class AuthPcController extends BaseController
{
    @Autowired
    private IAuthPcService authPcService;

    /**
     * 查询授权计算机列表
     */
    @PreAuthorize("@ss.hasPermi('auth:pc:list')")
    @GetMapping("/list")
    public TableDataInfo list(AuthPc authPc)
    {
        startPage();
        List<AuthPc> list = authPcService.selectAuthPcList(authPc);
        return getDataTable(list);
    }

    /**
     * 导出授权计算机列表
     */
    @PreAuthorize("@ss.hasPermi('auth:pc:export')")
    @Log(title = "授权计算机", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AuthPc authPc)
    {
        List<AuthPc> list = authPcService.selectAuthPcList(authPc);
        ExcelUtil<AuthPc> util = new ExcelUtil<AuthPc>(AuthPc.class);
        util.exportExcel(response, list, "授权计算机数据");
    }

    /**
     * 获取授权计算机详细信息
     */
    @PreAuthorize("@ss.hasPermi('auth:pc:query')")
    @GetMapping(value = "/{pcId}")
    public AjaxResult getInfo(@PathVariable("pcId") Long pcId)
    {
        return AjaxResult.success(authPcService.selectAuthPcByPcId(pcId));
    }

    /**
     * 新增授权计算机
     */
    @PreAuthorize("@ss.hasPermi('auth:pc:add')")
    @Log(title = "授权计算机", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AuthPc authPc)
    {
        return toAjax(authPcService.insertAuthPc(authPc));
    }

    /**
     * 修改授权计算机
     */
    @PreAuthorize("@ss.hasPermi('auth:pc:edit')")
    @Log(title = "授权计算机", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AuthPc authPc)
    {
        return toAjax(authPcService.updateAuthPc(authPc));
    }

    /**
     * 删除授权计算机
     */
    @PreAuthorize("@ss.hasPermi('auth:pc:remove')")
    @Log(title = "授权计算机", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pcIds}")
    public AjaxResult remove(@PathVariable Long[] pcIds)
    {
        return toAjax(authPcService.deleteAuthPcByPcIds(pcIds));
    }
}
